Skip to content

feat(deploy): add shared check-published-deploy-constants script#238

Open
thedavidmeister wants to merge 2 commits into
mainfrom
issue-236-check-deploy-constants
Open

feat(deploy): add shared check-published-deploy-constants script#238
thedavidmeister wants to merge 2 commits into
mainfrom
issue-236-check-deploy-constants

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Closes #236

Adds a parameterized check-published-deploy-constants script to lib/ and exposes it on sol-shell PATH. Consumers (raindex, rain.math.float, etc.) can drop their bespoke copies and call the shared version via:

nix develop github:rainlanguage/rainix#sol-shell \
  -c check-published-deploy-constants <soldeer-pkg> <deploy-lib.sol> PREFIX1 PREFIX2 ...

The script queries the soldeer registry for all published versions of the named package, then asserts <PREFIX>_{ADDRESS,CODEHASH}_<ver> constants exist in the given Solidity file. Exits 0 in all cases; prints OK, MISSING: <names>, or SKIP: <reason> (if the registry is unreachable).

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • New Features
    • Added a new check task to validate published deployment constants for Solidity packages.
    • Exposed the task as part of the available build/check outputs.
  • Bug Fixes
    • The new check skips gracefully when no published versions are available, while reporting missing constants when needed.
  • Tests
    • Added coverage to confirm the new check command is available in the development shell.

Parameterizes the deploy-constants completeness check that raindex
currently hardcodes in script/check-published-deploy-constants.sh.
Exposes check-published-deploy-constants on sol-shell PATH so any
consumer repo can run it via:

  nix develop github:rainlanguage/rainix#sol-shell \
    -c check-published-deploy-constants <pkg> <lib.sol> <PREFIX1> ...

Co-Authored-By: Claude <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new parameterized shell script lib/check-published-deploy-constants.sh is added. It queries the Soldeer API for published versions of a package and checks that a Solidity file contains matching DEPLOYED_ADDRESS_<ver> and DEPLOYED_CODEHASH_<ver> constants. The script is wired as a Nix mkTask (rainix-check-deploy-constants) with curl and gnugrep as inputs, added to sol-tasks, exposed in packages, and covered by a Bats PATH-resolution test.

Changes

Deploy Constants Completeness Check

Layer / File(s) Summary
Script implementation
lib/check-published-deploy-constants.sh
New Bash script with strict mode: validates args, fetches published Soldeer versions from the API, iterates versions and prefixes to check for DEPLOYED_ADDRESS_<ver> / DEPLOYED_CODEHASH_<ver> constants in a Solidity file, prints SKIP, MISSING:<names>, or OK.
Nix task wiring
flake.nix
Defines rainix-check-deploy-constants as a mkTask running the script with curl/gnugrep build inputs; appends it to sol-tasks and the exported packages set.
Bats test
test/bats/devshell/sol-shell/sol-tasks.test.bats
Adds a test case asserting check-published-deploy-constants is on PATH in the sol-shell.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A hop through the registry, versions in hand,
Checking each constant across every land.
ADDRESS and CODEHASH, all must align,
Or MISSING is printed along the vine.
With curl and grep the bunny ensures,
That deploy constants stay pure! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a shared deploy-constants check script.
Linked Issues check ✅ Passed The PR adds the shared parameterized script, exposes it on sol-shell, and covers the expected OK/MISSING/SKIP behavior.
Out of Scope Changes check ✅ Passed The changes stay focused on the shared deploy-constants check, its wiring, and a PATH test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-236-check-deploy-constants

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…dInputs list

Co-Authored-By: Claude <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/check-published-deploy-constants.sh`:
- Around line 26-29: The argument validation in check-published-deploy-constants
should follow the same success-only CLI contract as the rest of the script, so
replace the early failure exit with a zero-status path that emits one of the
allowed statuses instead of aborting. Update the main guard around the usage
check and any caller-facing output so the script never returns a nonzero code
for this case, keeping the observable results limited to OK, MISSING, or SKIP.
- Around line 35-42: The version lookup in check-published-deploy-constants.sh
is treating parse failures the same as fetch failures because the `versions`
pipeline ends with `|| true`, so `grep`/`cut` empties fall through to the `SKIP`
branch. Update the shell logic around the `curl`/`grep`/`cut` pipeline so only
real connectivity/request failures are ignored, while malformed or unexpected
API responses are detected separately and reported as a parse/API drift issue
instead of `SKIP`; use the existing `versions` assignment and the `if [ -z
"$versions" ]` check to split these cases clearly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b2d7aea4-4d8e-440f-81a9-ac59b36215bc

📥 Commits

Reviewing files that changed from the base of the PR and between 51e62ff and c882a42.

📒 Files selected for processing (3)
  • flake.nix
  • lib/check-published-deploy-constants.sh
  • test/bats/devshell/sol-shell/sol-tasks.test.bats

Comment on lines +26 to +29
if [ "$#" -lt 3 ]; then
printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2
exit 1
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the CLI contract success-only here too.

The linked issue/PR contract says callers should only see OK, MISSING, or SKIP and a zero exit status. exit 1 adds a fourth behavior that can break consumers wiring this into CI.

Proposed fix
 if [ "$#" -lt 3 ]; then
-  printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2
-  exit 1
+  printf 'SKIP: usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n'
+  exit 0
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$#" -lt 3 ]; then
printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2
exit 1
fi
if [ "$#" -lt 3 ]; then
printf 'SKIP: usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n'
exit 0
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/check-published-deploy-constants.sh` around lines 26 - 29, The argument
validation in check-published-deploy-constants should follow the same
success-only CLI contract as the rest of the script, so replace the early
failure exit with a zero-status path that emits one of the allowed statuses
instead of aborting. Update the main guard around the usage check and any
caller-facing output so the script never returns a nonzero code for this case,
keeping the observable results limited to OK, MISSING, or SKIP.

Comment on lines +35 to +42
versions=$(
curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \
| grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
) || true

if [ -z "$versions" ]; then
printf 'SKIP: could not fetch published soldeer versions'
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don't collapse parse failures into a connectivity SKIP.

Because || true is attached to the whole pipeline, any successful fetch that produces no grep matches also lands in SKIP: could not fetch.... That masks parser/API drift as a benign skip.

Proposed fix
-versions=$(
-  curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \
-    | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
-) || true
-
-if [ -z "$versions" ]; then
+response=$(curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null) || {
   printf 'SKIP: could not fetch published soldeer versions'
   exit 0
-fi
+}
+
+versions=$(
+  printf '%s' "$response" \
+    | grep -oE '"version":"[0-9][0-9.]*"' \
+    | cut -d'"' -f4 \
+    | sort -u
+)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
versions=$(
curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \
| grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
) || true
if [ -z "$versions" ]; then
printf 'SKIP: could not fetch published soldeer versions'
exit 0
response=$(curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null) || {
printf 'SKIP: could not fetch published soldeer versions'
exit 0
}
versions=$(
printf '%s' "$response" \
| grep -oE '"version":"[0-9][0-9.]*"' \
| cut -d'"' -f4 \
| sort -u
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/check-published-deploy-constants.sh` around lines 35 - 42, The version
lookup in check-published-deploy-constants.sh is treating parse failures the
same as fetch failures because the `versions` pipeline ends with `|| true`, so
`grep`/`cut` empties fall through to the `SKIP` branch. Update the shell logic
around the `curl`/`grep`/`cut` pipeline so only real connectivity/request
failures are ignored, while malformed or unexpected API responses are detected
separately and reported as a parse/API drift issue instead of `SKIP`; use the
existing `versions` assignment and the `if [ -z "$versions" ]` check to split
these cases clearly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upstream the versioned deploy-constants completeness check into rainix

1 participant